package vegetables;

import java.util.ArrayList;
import java.util.Scanner;

public class foodOperator {
    private ArrayList<food> foodList=new ArrayList<>();
    public void addFood(){
        food f=new food();

        Scanner sc=new Scanner(System.in);
        System.out.println("请输入菜品名称：");
        String name=sc.next();
        f.setName(name);

        System.out.println("请输入菜品价格：");
        double price=sc.nextDouble();
        f.setPrice(price);

        System.out.println("请输入菜品介绍");
        String description=sc.next();
        f.setDescription(description);

        foodList.add(f);
        System.out.println("上架成功!");
    }
    public void showallfood(){
        if(foodList.size()==0) {
            System.out.println("还未上架菜品");
            return;
        }
            for (int i = 0; i < foodList.size(); i++) {
                System.out.println(foodList.get(i).getName());
                System.out.println(foodList.get(i).getPrice());
                System.out.println(foodList.get(i).getDescription());
                System.out.println("---------------------------------------------");
            }
    }

    public void start() {
        while (true) {
            System.out.println("请选择功能：");
            System.out.println("1.上架菜品");
            System.out.println("2.展示菜品");
            System.out.println("3.退出");

            Scanner sc = new Scanner(System.in);
            System.out.println("请输入命令；");
            String choice = sc.next();
            switch (choice) {
                case "1":
                    addFood();
                    break;
                case "2":
                    showallfood();
                    break;
                case "3":
                    System.out.println("下次再来");
                    return;
                default:
                    System.out.println("输入的命令不存在");
            }
        }
    }
}
